import network from '../network'

export default {
    /**
     * 发送短信验证码
     * @param {*} phone 手机号
     * @param {*} type 0:手机号验证码登录，3:忘记密码
     * @returns 
     */
	getSmsCode: (phone,type) => {
		return network({
			url: `/wxMini/auth/sendCode`,
			method: 'post',
            data: {
				phone,
				type
			}
		})
	},
	/**
	 * 验证码登录
	 * @param {*} phone 
	 * @param {*} code 
	 * @param {*} loginType 1:微信登录 2:手机号验证码登录 3:密码登录
	 * @returns 
	 */
	loginByCode: (phone,code) => {
		return network({
			url: `/wxMini/auth/login`,
			method: 'post',
            data: {
				phone,
				code,
				loginType:2
			}
		})
	},
	loginByPassword: (username,password) => {
		return network({
			url: `/wxMini/auth/login`,
			method: 'post',
            data: {
				phone: username,
				password,
				loginType:3
			}
		})
	},
	/**
	 * 获取用户信息
	 * @returns 
	 */
	getUserInfo: () => {
		return network({
			url: `/getInfo`,
			method: 'get',
		})
	},
	/**
	 * 重置密码
	 * @param {*} data 
	 * @returns 
	 */
	resetPassword: (data) => {
		return network({
			url: `/wxMini/auth/forgetPassword`,
			method: 'post',
			data
		})
	}
}
